
export const BeforeCompile = (options) => (shader) => {
    const { uniforms, vertexShader_common, vertexShader_begin_vertex, fragmentShader_common, fragmentShader_dithering_fragment, gsapCallBack } = options;

    for (const key in uniforms) {
        shader.uniforms[key] = uniforms[key];
    }

    shader.vertexShader = shader.vertexShader.replace(
        "#include <common>",
        `
            #include <common>
            ${vertexShader_common}
        `
    );

    shader.vertexShader = shader.vertexShader.replace(
        "#include <begin_vertex>",
        `
            #include <begin_vertex>
            ${vertexShader_begin_vertex}
        `
    );
    shader.fragmentShader = shader.fragmentShader.replace(
        "#include <common>",
        `
            #include <common>
            ${fragmentShader_common}
              `
    );
    shader.fragmentShader = shader.fragmentShader.replace(
        "vLightMapUv",
        `
            ${fragmentShader_dithering_fragment}
        `
    );

    gsapCallBack?.(shader);
}